#include "test/naive/fixture.h"

#include "megdnn/oprs/linalg.h"
#include "test/common/checker.h"

using namespace megdnn;
using namespace test;

TEST_F(NAIVE, CROSS) {
    Checker<Cross> checker(handle(), /* check_dispatch */ false);

    Cross::Param param{2, 0, -3};

    TensorND A = TensorValue(
            {2, 2, 3, 3}, dtype::Float32(),
            {0.14156187, 0.91729394, 0.74985146, 0.06110339, 0.67560272, 0.38569672,
             0.63086542, 0.96403808, 0.44215527, 0.04618851, 0.17031024, 0.83291294,
             0.15374447, 0.57640597, 0.90293485, 0.55324231, 0.75830697, 0.43003672,
             0.18093289, 0.73350109, 0.38130576, 0.29138499, 0.77249111, 0.0878262,
             0.11699259, 0.73904961, 0.52122415, 0.10095503, 0.15948783, 0.88822725,
             0.12915866, 0.59800798, 0.17838123, 0.37576929, 0.9885241,  0.25812663});

    TensorND B = TensorValue(
            {3, 2, 2, 3}, dtype::Float32(),
            {0.87391774, 0.65328165, 0.44478127, 0.94795241, 0.84836271, 0.8054875,
             0.44598355, 0.50247015, 0.36997338, 0.77503215, 0.87235448, 0.21397323,
             0.85153319, 0.16009368, 0.77536431, 0.04486964, 0.37626156, 0.81259061,
             0.08839276, 0.50477703, 0.91626721, 0.44417563, 0.03038398, 0.21980224,
             0.71472471, 0.85791626, 0.40345219, 0.16018583, 0.38511319, 0.23809232,
             0.58711753, 0.92031592, 0.65426633, 0.14788665, 0.73273333, 0.3182309});

    TensorND C = TensorValue(
            {2, 3, 2, 3}, dtype::Float32(),
            {-0.49353074, 0.42527416,  -0.18722123, -0.0001961,  -0.06334022,
             -0.13446194, 0.45014671,  -0.157173,   -0.10586683, 0.51704864,
             0.57773064,  0.14807902,  0.0671453,   -0.29450591, 0.40985739,
             -0.14366998, -0.42492013, -0.05048549, 0.16073594,  0.3378806,
             -0.42011888, -0.14780672, 0.40814509,  0.00002961,  -0.0540521,
             -0.30370236, -0.05663646, 0.27630338,  0.74548138,  -0.22742917,
             -0.11395976, -0.01789922, 0.31688461,  -0.05526035, -0.51682907,
             0.15706553});

    checker.set_param(param).exect(Testcase{A, B, {}}, Testcase{{}, {}, C});
}
